package org.csu.mypetstoreplus.controller;

import org.csu.mypetstoreplus.common.BaseResponse;

import org.csu.mypetstoreplus.service.OrderService;
import org.csu.mypetstoreplus.vo.OrderVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
public class OrderController
{

    @Autowired
    private OrderService orderService;

    //生成新Order
    @PostMapping("/orders")
    public BaseResponse<Object> newOrder(@RequestBody OrderVO orderVO) {
        orderService.newOrder(orderVO);
        return BaseResponse.createForSuccess();
    }

    //查看Order详情
    @GetMapping("/orders/{id}")
    public BaseResponse<Object> getOrder(@PathVariable int id) {
        return BaseResponse.createForSuccess(orderService.getOrder(id));
    }
    
}
